﻿using System.Collections.Generic;
using FollowMe.Model;
using FollowMe.Services.Response;

namespace FollowMe.Services.Mappers
{
    public static class MessageExtensionMethods
    {
        public static MessageView ConvertToMessageView(this Message message)
        {
            return new MessageView
            {
                messageID = message.MessageId,
                memberFromID = message.MessageSenderId,
                memberToID = message.MessageReceiverId,
                content = message.Content,
                date = message.Date,
                read = message.Read,
                lattitude = message.Lattitude,
                longitude = message.Longitude,
                messageType = message.MessageType
            };
        }

        public static IList<MessageView> ConvertToMessageViews(this IEnumerable<Message> messages)
        {
            IList<MessageView> messageViews = new List<MessageView>();
            foreach (Message message in messages)
            {
                messageViews.Add(message.ConvertToMessageView());
            }

            return messageViews;
        }
    }
}